<div class='fui-page fui-page-current'>
    <div class="fui-header">
		<div class="fui-header-left">
			<a class="back" ng-click="goback()"></a>
		</div>
		<div class="title">充值中心</div> 
		<div class="fui-header-right">&nbsp;</div>
    </div>
    <div class="fui-content">
		<div class="fui-cell-group" style="margin-top:0">
			<div class="fui-tab fui-tab-success">
			  <a ng-repeat="(k,v) in pagedata.gift_type" ng-class="{'active':pagedata.params.type==k}" ng-click="pagedata.params.type=k;pagedata.getlist();">{{v}}充值</a>
			</div>
		</div>
		<div class="radius" ng-include="sys_html('common/_jifen')"></div>
	</div>
<div class="fui-navbar-tip">面值<red>{{pagedata.goods.oldprice}}</red>的{{pagedata.goods.typetitle}},现只需<red>{{pagedata.goods.price}}</red>元，数量有限哦！</div>
<div class="fui-navbar order-create-checkout">
    <a href="javascript:;" class="nav-item total" style="text-align:left;padding-left:0.5rem">
        <span class="text-danger bigprice">&yen; 
			<span class="totalprice" style="font-size:1.2rem">{{price(pagedata.goods.price) || '0.00'}}<span style="font-size:0.5rem">(活动价)</span></span>
		</span>
    </a>
    <a href="javascript:;" class="nav-item btn btn-danger buybtn" ng-if="!pagedata.order_id" ng-click="pagedata.buy(pagedata.goods.id)" >
		立即支付
	</a>
	<a href="javascript:;" class="nav-item btn btn-danger buybtn" ng-if="pagedata.order_id" ng-click="access_json('jy_xunichong/order.list//id='+pagedata.order_id+'&fromcreate=1')" >
		查看订单
	</a>
</div>
</div>
<!-- 二维码-->
<div ng-if="pagedata.showbuyewm" class="popup">
	<div class="popup-body">
		<div class="popup-center" style="background:#fc6d60">
			<style>
				input{ caret-color: #fff}
				.fui-cell-group .fui-cell .fui-cell-info  ::-webkit-input-placeholder{
					color: #fff
				}
				.fui-cell-group .fui-cell .fui-cell-info {
					font-size: 0.85rem;
					color: #fff;
				}
			</style>
			<i class="closed icon icon-cuowu" ng-click="pagedata.showbuyewm=false"></i>
			 <div class='fui-cell-group fui-cell-group-o' style="margin:0.5rem 2rem;padding-top:0.5rem;background:#fc6d60">
				<div class='fui-cell-title c' style="color:#fff">您正在进行“扫码支付”操作
				</div>
				<div class='fui-cell-title c'>
					<img style="width:8rem;height:8rem" ng-src="{{tomedia(pagedata.goods.group.ewm) || '../core/resource/images/nopic.jpg'}}"/>
				</div>
			</div>
			<div class="weui_btn_area" style="margin:2rem;">
				<a class='weui_btn weui_btn_primary' style="border-radius:1rem;background-color:#fff;color:#fc6d60" ng-click="access_json('/myhome/')">我已支付完成</a>
			</div>
		</div>
	</div>
</div>
<script>
scope.pagedata.buy=function(){
	var id=scope.pagedata.goods.id
	if(!id){
		scope.message('请选择要充值的面额！');
	}
	scope.post_json('jy_xunichong/goods.jifen/buy/',{'id':id},function(res){
		console.log('pay_id');console.log(res);
		if(scope.pagedata.goods.group.pay_type==1){
			scope.pagedata.showbuyewm=true;
			scope.$evalAsync();
			return true;
		}
		if(scope.pagedata.goods.group.pay_type==2){
			scope.access_json(scope.pagedata.goods.group.payurl);
			scope.$evalAsync();
			return true;
		}
		scope.pagedata.order_id=res.order_id;
		require(['tool'],function(tool){
			tool.pay(res.pay_id,function(res){
				console.log('收到支付结果！');
				if(res.type=='success'){
					scope.message('兑换成功！','','jy_xunichong/order.list/');
				}else{
					scope.message('兑换失败！'+res.message,'','goback');
				}
			});
		});
	});
}
</script>